<template>
  <div class="loans">
    <div class="tops">
      <div class="tops-main">
        <div class="tops-text">贷款总额</div>
        <div class="pay" @click="rechargeClick">充值</div>
      </div>
      <div class="price">¥40,000</div>
      <div class="tops-bottom">
        <div class="bottom-items">
          <p>贷款金额(元)</p>
          <div class="bottom-price">¥40,000</div>
        </div>
        <div class="bottom-items">
          <p>消费金额(元)</p>
          <div class="bottom-price">¥40,000</div>
        </div>
      </div>
    </div>
    <div class="tab-control">
      <div class="contain">
        <div
          class="items"
          v-for="(item, index) in title"
          :key="index"
          @click="itemsClick(index)"
        >
          <div class="title" :class="currentIndex == index ? 'active' : ''">
            {{ item }}
            <span class="line"></span>
          </div>
        </div>
      </div>
    </div>
    <div class="pay-list" v-if="currentIndex == 0">
      <div class="pay-list-item" v-for="index in 5" :key="index">
        <p class="title">私密产品名字</p>
        <div class="desc">
          <div class="lefts">
            <div class="pay-price">售价:¥345.00</div>
            <div class="pay-count">数量:10</div>
            <div class="pay-price">小价:¥345.00</div>
          </div>
          <div class="rights">2020/11/23</div>
        </div>
      </div>
    </div>
    <div class="pay-list top-up" v-else>
      <div class="pay-list-item" v-for="index in 5" :key="index">
        <p class="title">
          <span>贷款充值</span>
          <span class="price">+<span> ¥3456.00</span></span>
        </p>
        <div class="desc">
          <div class="lefts">充值时间:2020/11/23</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getGoodsPayMent} from '@/api/payment';
export default {
  name: 'loans',
  data() {
    return {
      title: ['贷款明细', '充值明细'],
      currentIndex: 0,
      payList:[]
    }
  },
  created() {
    this.getGoodsPayMents()
  },
  methods: {
    itemsClick(index) {
      this.currentIndex = index
    },
    rechargeClick() {
      this.$router.push('/recharge')
    },
    async getGoodsPayMents() {
      const datas = {
        userId: localStorage.getItem('token'),
        page: 1,
        pageSize: 5
      }
      const res = await getGoodsPayMent(datas)
      console.log(res);
    }
  },
}
</script>

<style lang="scss" scoped>
.loans {
  font-size: 14px;
  // padding: 12px;
}
.tops {
  height: 213px;
  background: linear-gradient(137deg, #31245b 0%, #110c24 100%);
  box-shadow: 0px 3px 9px 0px rgba(62, 57, 51, 0.12);
  border-radius: 12px;
  padding: 0 20px 0 30px;
  margin: 12px 12px 20px;
  overflow: hidden;
  color: #fff;
  margin-bottom: 20px;
  .tops-main {
    display: flex;
    justify-content: space-between;
    height: 32px;
    margin-top: 30px;
    .tops-text {
      font-weight: 400;
      color: #dbd9de;
    }
    .pay {
      width: 68px;
      height: 32px;
      text-align: center;
      line-height: 32px;
      background: #fad28c;
      border-radius: 16px;
      color: #884312;
    }
  }
  .price {
    font-size: 32px;
    font-weight: 600;
    color: #f7f6fb;
    padding-bottom: 20px;
    border-bottom: 1px solid #665e75;
  }
  .tops-bottom {
    display: flex;
    margin-top: 20px;
    .bottom-items:nth-child(1) {
      margin-right: 93px;
    }
    p {
      font-size: 12px;
      color: #dbd9de;
    }
    .bottom-price {
      font-size: 20px;
      font-weight: 400;
      color: #f7f6fb;
    }
  }
}
.pay-list {
  padding: 0 12px;
}
.pay-list-item {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 72px;
  background: #ffffff;
  border-bottom: 1px solid #f7f6fb;
  // &:nth-child(1) {
  //   border-top: 1px solid #f7f6fb;
  // }
  .title {
    color: #1f0d44;
    font-size: 16px;
  }
  .desc {
    display: flex;
    justify-content: space-between;
    color: #afabb7;
    font-size: 12px;
    .lefts {
      display: flex;
      .pay-count {
        margin: 0 12px;
      }
    }
  }
}
.top-up {
  .title {
    display: flex;
    justify-content: space-between;
    .price {
      color: #622CCC;
      span {
        font-size: 16px;
      }
    }
  }
}
.tab-control {
  width: 100%;
  height: 44px;
  line-height: 44px;
  font-size: 16px;
  // background: #f7f6fb;
  background-color: #fff;
  border-bottom: 1px solid #f7f6fb;
  .contain {
    display: flex;
    justify-content: space-between;
    color: #665e75;
    margin: 0 75px;
  }
}
.active {
  font-size: 16px;
  font-weight: 800;
  color: #1f0d44;
  .line {
    display: block;
    margin: -8px auto 0;
    width: 20px;
    height: 3px;
    background: linear-gradient(225deg, #622ccc 0%, #b620e0 100%);
    border-radius: 2px;
  }
}
</style>